#pragma once

#include "Stereotype.h"

#include "Image.h"
#include "Profile.h"

namespace uml {

Stereotype::Stereotype(const QString& umlType)
    : Class(umlType) {}

void Stereotype::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Class::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(icons_, "icons", json, errorList);
    profile_ = JsonSerializable::create<Profile>(json.value("profile"), errorList);

}

void Stereotype::toJson(QJsonObject& json) {
    Class::toJson(json);
    JsonSerializable::toJsonArray(icons_, "icons", json);
    if (profile_) {
        QJsonObject profile_json;
        profile_->toJson(profile_json);
        json.insert("profile", profile_json);
    }
}

/// <summary>
/// containingProfile
    /// The query containingProfile returns the closest profile directly or indirectly
    /// containing this stereotype.
/// </summary>
    /// <code>
    /// result = (self.namespace.oclAsType(Package).containingProfile())
    /// </code>
shared_ptr<Profile> Stereotype::containingProfile() const
{
    return nullptr;
}

/// <summary>
/// icons getter
/// Stereotype can change the graphical appearance of the extended model element by
/// using attached icons. When this association is not null, it references the
/// location of the icon content to be displayed within diagrams presenting the
/// extended model elements.
/// </summary>
vector<shared_ptr<Image>>& Stereotype::icons() {
    return icons_;
}

/// <summary>
/// profile getter
/// The profile that directly or indirectly contains this stereotype.
/// </summary>
shared_ptr<Profile> Stereotype::profile() const {
    return profile_;
}

/// <summary>
/// profile setter
/// The profile that directly or indirectly contains this stereotype.
/// </summary>
void Stereotype::setProfile(shared_ptr<Profile> value) {
    profile_ = value;
}

} // namespace uml
